﻿using System;
using System.Globalization;
using System.IO;
using Avalonia.Data.Converters;
using Avalonia.Media.Imaging;

namespace MilkTeaMachine.OfflineClient.Utils.Converters;

public class BoolToImageSourceConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is not bool b) return null;
        var path = b
            ? Path.Combine(App.SharedResourceRootPath, "checked.png")
            : Path.Combine(App.SharedResourceRootPath, "unchecked.png");
        return new Bitmap(path);
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return null;
    }
}